package com.henrybit.exception;

/**
 * 异常控制类<br>
 * @author henrybit
 * @version 1.0
 */
public class BaseException extends Exception {
	public BaseException() {
		this.e = new Throwable("未知异常");
	}
	public BaseException(Throwable e) {
		this.e = e;
	}
	public BaseException(Throwable e,int code) {
		this.e = e;
		this.code = code;
	}
	public BaseException(Throwable e,int code, String message) {
		this.e = e;
		this.code = code;
		this.message = message;
	}
	public BaseException(int code, String message) {
		this.code = code;
		this.message = message;
	}
	public BaseException(String message) {
		this.code = 0;
		this.message = message;
	}
	/**异常编码*/
	private int code;
	/**异常信息描述*/
	private String message;
	/**捕获的异常类*/
	private Throwable e;
	
	//getter or setter
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		StringBuilder exceptionMsg = new StringBuilder();
		exceptionMsg.append("异常编码状态:").append(code).append(",异常描述:").append(message).append(",:").append(e.toString());
		return exceptionMsg.toString();
	}
}
